import 'package:mybase/base/tool/web/FFWebManager.dart';

class FFWebHelp {
  // Uri path = "/t=123&b=234&c=sdf"; 返回map
  static Map<String, String> uriToMap(String uriPath) {
    // 去掉路径前面的 '/'
    if (uriPath.startsWith('/')) {
      uriPath = uriPath.substring(1);
    }

    // 使用 Uri.splitQueryString 方法解析路径字符串
    Map<String, String> queryParams = Uri.splitQueryString(uriPath);
    return queryParams;
  }

  // 设置标题和路径
  static setTitleAndPath({
    required String title,
    required String path,
  }) {
    FFWebManager().title = title;
    FFWebManager().path = path;
  }

  // 重置标题和路径
  // windown = html.window  import 'dart:html' as html;
  static resetTitleAndPath(dynamic window) {
    var webManager = FFWebManager();
    window.history.pushState(null, webManager.title ?? "", webManager.path);
  }
}
